﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _19_事件练习
{
    class Person
    {
        public event Action Shoot;
        public void Fire()
        {
            Console.WriteLine("人开枪了");
            Shoot.Invoke();//事件有且只能在类的内部调用，外部只能绑定(+=/-=)
        }
    }

    internal class Program
    {
        static void Main(string[] args)
        {
            Person person = new Person();
            for (int i = 1; i <= 3; i++)
            {
                int Index = i;
                person.Shoot += () => Console.WriteLine("小鸟-{0}飞走了~", Index);
            }
            //人开枪了
            person.Fire();
            Console.ReadKey();
        }
    }
}
